/**
 * Created by Administrator on 2017/5/3 0003.
 */
var Page0={
    create:function () {
        var page={};

        page.ui=new PIXI.DisplayObjectContainer();
        var logo=Easy.CreateSprite('assets/images/logo.png',735,381,0.5,0.5,0);
        page.ui.addChild(logo);
        logo.scale.set(0.2);

        var leaf0=Easy.CreateSprite('assets/images/leaf0.png',204,102,0.5,0.5,0);
        page.ui.addChild(leaf0);
        var mask_0=new PIXI.Graphics();
        mask_0.beginFill(0,1);
        mask_0.drawRect(-356/2,-302/2,356,302);
        mask_0.endFill();
        mask_0.x=-106;
        mask_0.y=-137;
        page.ui.addChild(mask_0);
        leaf0.mask=mask_0;
        TweenMax.to(leaf0, 1.5, {y:96,repeat:-1,yoyo:true,ease:Cubic.easeInOut});

        var leaf1=Easy.CreateSprite('assets/images/leaf1.png',1032,467,0.5,0.5,0);
        leaf1.rotation=-2*Math.PI/180
        page.ui.addChild(leaf1);
        var mask_1=new PIXI.Graphics();
        mask_1.beginFill(0,0.5);
        mask_1.drawRect(-356/2,-302/2,356,302);
        mask_1.endFill();
        mask_1.x=1350;
        mask_1.y=269;
        page.ui.addChild(mask_1);
        leaf1.mask=mask_1;
        // TweenMax.to(leaf1, 2, {rotation:2*Math.PI/180,repeat:-1,yoyo:true,ease:Cubic.easeInOut});

        var tip=Easy.CreateSprite('assets/images/tip.png',915,366,0.5,0.5,0);
        page.ui.addChild(tip);
        TweenMax.to(tip, 1, {x:915-15,repeat:-1,yoyo:true,ease:Cubic.easeInOut});

        var shadow=Easy.CreateSprite('assets/images/shadow.png',563,246,0.5,0.5,0);
        page.ui.addChild(shadow);

        page.Init=function () {
            TweenMax.to(logo.scale, 0.5, {delay:0.4,x:0.4,y:0.4,ease:Back.easeOut});
            TweenMax.to(logo, 0.5, {delay:0.4,alpha:1});
            TweenMax.to(logo, 3, {delay:0.5,bezier:[{x:735, y:381}, {x:866, y:301}, {x:919, y:140}, {x:825, y:-1}, {x:649, y:3}, {x:566, y:113}],ease:Cubic.easeInOut});
            TweenMax.to(logo.scale, 3, {delay:1,x:1,y:1,ease:Cubic.easeInOut});
            TweenMax.to(logo, 3, {delay:1,rotation:Math.PI*4,ease:Cubic.easeInOut});
            TweenMax.to(logo, 2, {delay:5,y:246,ease:Linear.easeNone});

            TweenMax.to(shadow, 0.5, {delay:6.8,alpha:1,ease:Linear.easeNone});

            TweenMax.to(leaf0, 2, {delay:7,alpha:1,ease:Linear.easeNone});
            TweenMax.to(leaf1, 2, {delay:7.3,alpha:1,ease:Linear.easeNone});
            TweenMax.to(mask_0, 2, {delay:7,x:204,y:103,ease:Cubic.easeInOut});
            TweenMax.to(mask_1, 2, {delay:7.3,x:1027,y:459,ease:Cubic.easeInOut});

            TweenMax.to(tip, 1, {delay:7.5,alpha:1,onComplete:function () {
                document.dispatchEvent(new CustomEvent('Main_EnableTrue'))
            }});

            setTimeout(function () {
                document.dispatchEvent(new CustomEvent('Main_PDStart'))
            },7000);
        };
        page.Out=function () {
            TweenMax.to(shadow, 1, {delay:0,alpha:0,ease:Linear.easeNone});
            TweenMax.to(tip, 1, {delay:0,alpha:0,ease:Linear.easeNone});
            TweenMax.to(logo, 1, {delay:0,alpha:0,ease:Linear.easeNone});
            TweenMax.to(leaf0, 1, {delay:0.1,alpha:0,ease:Linear.easeNone});
            TweenMax.to(leaf1, 1, {delay:0.2,alpha:0,ease:Linear.easeNone});
            document.dispatchEvent(new CustomEvent('Main_PDEnd'))

        }
        page.In=function () {
            
        }

        return page;
    }
}